//
//  UIColor+iGallery.m
//  jingdongfang
//
//  Created by BOE on 2017/8/9.
//  Copyright © 2017年 ZhiYu Hao. All rights reserved.
//

#import "UIColor+iGallery.h"

@implementation UIColor (iGallery)

+ (UIColor *)colorWithHex:(NSString *)string
{
    NSString *cleanString = [string stringByReplacingOccurrencesOfString:@"#" withString:@""];
    if([cleanString length] == 3) {
        cleanString = [NSString stringWithFormat:@"%@%@%@%@%@%@",
                       [cleanString substringWithRange:NSMakeRange(0, 1)],[cleanString substringWithRange:NSMakeRange(0, 1)],
                       [cleanString substringWithRange:NSMakeRange(1, 1)],[cleanString substringWithRange:NSMakeRange(1, 1)],
                       [cleanString substringWithRange:NSMakeRange(2, 1)],[cleanString substringWithRange:NSMakeRange(2, 1)]];
    }
    if([cleanString length] == 6) {
        cleanString = [cleanString stringByAppendingString:@"ff"];
    }
    
    unsigned int baseValue;
    [[NSScanner scannerWithString:cleanString] scanHexInt:&baseValue];
    
    float red = ((baseValue >> 24) & 0xFF)/255.0f;
    float green = ((baseValue >> 16) & 0xFF)/255.0f;
    float blue = ((baseValue >> 8) & 0xFF)/255.0f;
    
    return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}

+ (UIColor *)c1Color{
    return [UIColor colorWithHex:@"#00ABE6"];
}

+ (UIColor *)c2Color {
    return [UIColor colorWithHex:@"#F2F4F8"];
}

+ (UIColor *)c3Color {
    return [UIColor whiteColor];
}

+ (UIColor *)c4Color {
    return [UIColor colorWithHex:@"#363636"];
}

+ (UIColor *)c5Color {
    return [UIColor colorWithHex:@"#929292"];
}

+ (UIColor *)c6Color {
    return [UIColor colorWithHex:@"#e2e2e2"];
}

+ (UIColor *)c7Color {
    return [UIColor colorWithHex:@"#DCC58F"];
}

+ (UIColor *)c8Color {
    return [UIColor colorWithHex:@"#00aae9"];
}

+ (UIColor *)appColor{
    return [UIColor c1Color];
}

+ (UIColor *)mainBackgroundColor{
    return [UIColor c2Color];
}
+ (UIColor *)mainRandomColor
{
//    NSArray <UIColor *>*colorArr = @[[UIColor colorWithHex:@"#d8cede"], [UIColor colorWithHex:@"#f3ead0"], [UIColor colorWithHex:@"#dcc6c0"], [UIColor colorWithHex:@"#cbd3dd"]];
//    return colorArr[arc4random() % 4];
    return [UIColor colorWithHex:@"#cbd3dd"];

}
@end
